import time

from PO项目实战.对象层.login_page import LoginPage


class LoginBusiness(LoginPage):
    
    def __init__(self, driver):
        super().__init__(driver)

    # 打开登录页面
    def open_login_page(self):
        self.driver.get(self.url)

    # 登录
    def do_login(self, username, password):
        self.username_ele.clear()
        self.username_ele.send_keys(username)
        self.password_ele.clear()
        self.password_ele.send_keys(password)
        self.button_ele.click()

    # 退出
    def do_logout(self):
        self.login_username_ele.click()
        time.sleep(1)
        self.logout_button_ele.click()

    # 获取title
    def get_title(self):
        return self.driver.title

    # 获取提示信息
    def get_alert_msg(self):
        return self.alert_ele.text

